unit AlterPassword;

interface

uses
  Windows, DB, ADODB, Controls, RzButton, StdCtrls, Classes, Forms, Sysutils;

type
  Talterpssfrm = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    RzButton1: TRzButton;
    RzButton2: TRzButton;
    procedure RzButton1Click(Sender: TObject);
    procedure RzButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    UserName:string;
  end;

var
  alterpssfrm: Talterpssfrm;

implementation

uses dbmodule;

{$R *.dfm}

procedure Talterpssfrm.RzButton1Click(Sender: TObject);
var
  tmpPs,newPs:string;
begin
  tmpPs:=Trim(Edit1.Text);
  if (Trim(Edit2.Text)<>Trim(Edit3.Text)) then begin
    Application.MessageBox(pchar('Please confire your new password.'),pchar('Error'),16);
    Edit2.Text:='';
    Edit3.Text:='';
    Edit2.SetFocus;
    Exit;
  end;
  newPs:=Trim(Edit2.Text);
  With dbmodulefrm.TSys_User do begin

    Active:=False;
    Filter:='NAME='''+UserName+'''';//+' And PASWD='''+tmpPs+'''';
    Filtered:=True;
    Active:=True;
    if tmpPs<>FieldByName('PASWD').AsString then begin
      Application.MessageBox(pchar('The password is wrong.'),pchar('Error'),16);
      Edit1.Text:='';
      Edit1.SetFocus;
    end else begin
      Edit;
      dbmodulefrm.TSys_User['PASWD']:=newPs;
      Post;
      Application.MessageBox(pchar('The password change succeed'),pchar('Messsage'),48);
    end;
    Active:=False;
    ModalResult:=MRok;
  end;

end;

procedure Talterpssfrm.RzButton2Click(Sender: TObject);
begin
  ModalResult:=MrCancel;
end;

end.
